﻿using Digitalmes.Infrastructure.IO.SerialPorts;

namespace Digitalmes.Infrastructure.IO;

/// <summary>
/// SerialPort 管理器程序启动后台服务。
/// </summary>
internal sealed class SerialPortsStartupHostedService(ISerialPortsManager serialPortsManager) : IHostedService
{
    public async Task StartAsync(CancellationToken cancellationToken)
    {
        await serialPortsManager.ReloadAsync(cancellationToken).ConfigureAwait(false);
    }

    public async Task StopAsync(CancellationToken cancellationToken)
    {
        await Task.CompletedTask;
        serialPortsManager.Dispose();
    }
}
